kineticscrolling: avoid stutter at tail of kinetic deceleration
authorChristian Hergert <chergert@redhat.com>
Sun, 24 Apr 2016 09:41:26 +0000 (02:41 -0700)
committerChristian Hergert <chergert@redhat.com>
Sun, 24 Apr 2016 10:49:20 +0000 (03:49 -0700)
When decelerating the kinetic scroll, we can get into a position where it
looks like we are stuttering. This happens because the amount we move is
so little that it takes multiple frames to make forward progress by one
pixel.

This prevents that by detecting when we have reached the slow stutter of
the deceleration and simply stops the deceleration phase immediately.

https://bugzilla.gnome.org/show_bug.cgi?id=765493

gtk/gtkkineticscrolling.c

index c33faee9c33903ac1d072e42e3f972568cec764f..29bf08567406226a7a028ae31ac79bb7296eb516 100644 (file)
@@ -152,6 +152,8 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
     {
     case GTK_KINETIC_SCROLLING_PHASE_DECELERATING:
       {
+        gdouble last_position = data->position;
+        gdouble last_time = data->t;
         gdouble exp_part;
 
         data->t += time_delta;
@@ -168,7 +170,8 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
           {
             gtk_kinetic_scrolling_init_overshoot(data, data->upper, data->position, data->velocity);
           }
-        else if (fabs(data->velocity) < 1)
+        else if (fabs(data->velocity) < 1 ||
+                 (last_time != 0.0 && fabs(data->position - last_position) < 1))
           {
             data->phase = GTK_KINETIC_SCROLLING_PHASE_FINISHED;
             data->position = round(data->position);